package org.september.pisces.task.entity;

import java.util.Date;

import org.september.smartdao.anno.AutoIncrease;
import org.september.smartdao.anno.Entity;
import org.september.smartdao.anno.Id;
import org.september.smartdao.anno.OptimisticLock;
import org.springframework.format.annotation.DateTimeFormat;

import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.annotation.DefaultValue;
import com.gitee.sunchenbin.mybatis.actable.annotation.IsAutoIncrement;
import com.gitee.sunchenbin.mybatis.actable.annotation.IsKey;
import com.gitee.sunchenbin.mybatis.actable.annotation.Table;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant;

import jakarta.validation.constraints.Size;


@Entity
@Table("simple_task")
public class SimpleTask {

	@Id
    @AutoIncrease
    @IsKey
    @IsAutoIncrement
    @Column(name = "id", length = 20)
	private Long id;
	
	/**
    *
    */
   @Size(max = 255)
   @Column(name = "task_name", length = 255, isNull = false)
   private String taskName;

   @Size(max = 255)
   @Column(name = "api", length = 255, isNull = false)
   private String api;
   
   @Size(max = 255)
   @Column(name = "remark", length = 255)
   private String remark;

   @Size(max = 64)
   @Column(name = "cron", length = 64, isNull = false)
   private String cron;
	
   @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
   @Column(name = "last_execute_time", type = MySqlTypeConstant.DATETIME)
   private Date lastExecuteTime;

   @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
   @Column(name = "next_execute_time", type = MySqlTypeConstant.DATETIME)
   private Date nextExecuteTime;
   
   @Column(name = "pause_flag", type = MySqlTypeConstant.SMALLINT, length = 6, isNull = false)
   @DefaultValue("0")
   public Integer pauseFlag;
   
   //任务状态，参考SimpleTaskStatus
   @Column(name = "run_status", type = MySqlTypeConstant.SMALLINT, length = 6, isNull = false)
   @DefaultValue("0")
   private Integer runStatus;
   
   //数据版本，避免错误更新
   @OptimisticLock
   @Column(name = "version", type = MySqlTypeConstant.INT, isNull = false)
   @DefaultValue("0")
   private Integer version;
   
   @Size(max = 128)
   @Column(name = "locker", length = 128, isNull = false,defaultValue = "")
   private String locker;
   
   @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
   @Column(name = "heart_beat_time", type = MySqlTypeConstant.DATETIME)
   private Date heartBeatTime;

   public String getTaskName() {
		return taskName;
	}

	public void setTaskName(String taskName) {
		this.taskName = taskName;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public String getCron() {
		return cron;
	}

	public void setCron(String cron) {
		this.cron = cron;
	}

	public Date getLastExecuteTime() {
		return lastExecuteTime;
	}

	public void setLastExecuteTime(Date lastExecuteTime) {
		this.lastExecuteTime = lastExecuteTime;
	}

	public Date getNextExecuteTime() {
		return nextExecuteTime;
	}

	public void setNextExecuteTime(Date nextExecuteTime) {
		this.nextExecuteTime = nextExecuteTime;
	}

	public int getPauseFlag() {
		return pauseFlag;
	}

	public void setPauseFlag(int pauseFlag) {
		this.pauseFlag = pauseFlag;
	}

	public String getApi() {
		return api;
	}

	public void setApi(String api) {
		this.api = api;
	}

	public int getRunStatus() {
		return runStatus;
	}

	public void setRunStatus(int runStatus) {
		this.runStatus = runStatus;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getLocker() {
		return locker;
	}

	public void setLocker(String locker) {
		this.locker = locker;
	}

	public Date getHeartBeatTime() {
		return heartBeatTime;
	}

	public void setHeartBeatTime(Date heartBeatTime) {
		this.heartBeatTime = heartBeatTime;
	}
}
